package copyHelperV2;

import java.io.File;

public class FileSize {
	
	private double size=0;
	private long bsize=0;
	private int lenght=0;


	public double getSize(File dirs) {

		double sizze;
			
		if(dirs.isFile()){
			this.size+=dirs.length();
		}
		else
			isDirB(dirs);
		sizze = this.size;
		this.size = 0;
				
		return (sizze / 1024) / 1024;
	}

	public long getSizeB(File dirs) {

		if(dirs.isFile()){
			this.bsize+=dirs.length();
		}
		else
			isDirB(dirs);
		long grosse = this.bsize;
		this.bsize = 0;
		
		return grosse;
		
	}
	
	public long getLenght(File dirs) {

		if(dirs.isFile()){
			if(!dirs.getName().endsWith(".ico")&&!dirs.getName().endsWith(".txt"))
			this.lenght++;
		}
		else
			isDirB(dirs);
		long grosse = this.bsize;
		this.bsize = 0;
		
		return grosse;
		
	}

	
	public void isDir(File ver){
		String[] list = ver.list();

		for (int i = 0; i < list.length; i++) {

			File uver = new File(ver.getAbsolutePath() + File.separator
					+ list[i]);
			if(uver.isFile()){
				this.size+= uver.length();
			}
			else
				isDir(uver);
			
			}
	}
	
	public void isDirB(File ver){
		String[] list = ver.list();

		for (int i = 0; i < list.length; i++) {

			File uver = new File(ver.getAbsolutePath() + File.separator
					+ list[i]);
			if(uver.isFile()){
				this.bsize+= uver.length();
			}
			else
				isDirB(uver);
			
			}
	}		
		public void isDirl(File ver){
			String[] list = ver.list();

			for (int i = 0; i < list.length; i++) {

				File uver = new File(ver.getAbsolutePath() + File.separator
						+ list[i]);
				if(uver.isFile()){
					this.lenght++;
				}
				else
					isDirB(uver);
				
				}
	
	
		}
}
